#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = '汤小洋'

import requests

'''
requests库：用于发送HTTP请求的库，在网络爬虫中经常使用
'''


def test_requests():
    url = 'http://www.51job.com/'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
    }
    response = requests.post(url, headers=headers)  # 发送post请求
    # print(response.status_code)

    if response.status_code == 200:
        data = response.content.decode('gbk')
        print(data)

        with open('index.html', mode='w', encoding='gbk') as f:
            f.write(data)


# test_requests()


'''
scrapy：是一个网络爬虫框架，用于抓取Web网站并从页面中提取结构化的数据
        用途广泛，可以用于数据挖掘、监测和自动化测试等
'''
